package com.nidu.demo.role;

import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.nidu.demo.role.dto.RoleAddCmd;
import com.nidu.demo.role.dto.RoleListQry;
import com.nidu.demo.role.dto.RolePageQry;
import com.nidu.demo.role.dto.RoleUpdateCmd;
import com.nidu.demo.common.enums.StatusEnum;
import com.nidu.demo.role.api.SysRoleService;
import com.nidu.demo.role.dto.*;
import com.nidu.demo.role.executor.command.*;
import com.nidu.demo.role.executor.query.*;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

/**
 * 角色服务实现类
 *
 * @author auto
 */
@Service
@RequiredArgsConstructor
public class SysRoleServiceImpl implements SysRoleService {

    private final RoleAddCmdExe addCmdExe;
    private final RoleUpdateCmdExe updateCmdExe;
    private final RoleDeleteCmdExe deleteCmdExe;
    private final RoleSingleQryExe singleQryExe;
    private final RoleListQryExe listQryExe;
    private final RolePageQryExe pageQryExe;

    @Override
    public SingleResponse<RoleCO> add(RoleAddCmd cmd) {
        return addCmdExe.execute(cmd);
    }

    @Override
    public SingleResponse<RoleCO> update(RoleUpdateCmd cmd) {
        return updateCmdExe.execute(cmd);
    }

    @Override
    public Response delete(Long id) {
        return deleteCmdExe.execute(id);
    }

    @Override
    public Response delete(Set<Long> ids) {
        return deleteCmdExe.execute(ids);
    }

    @Override
    public SingleResponse<RoleCO> getById(Long id) {
        return singleQryExe.execute(id);
    }

    @Override
    public MultiResponse<RoleCO> list(RoleListQry qry) {
        return listQryExe.execute(qry);
    }

    @Override
    public PageResponse<RoleCO> page(RolePageQry qry) {
        return pageQryExe.execute(qry);
    }

    @Override
    public Response updateStatus(Long id, StatusEnum status) {
        return updateCmdExe.updateStatus(id, status);
    }

} 